﻿// JScript File
function disableThis(obj, newCaption)//used to disable buttons after click - sanal 22 Apr 2008
{

    try {
        if (typeof (Page_ClientValidate) == 'function') Page_ClientValidate('');
        if (typeof (Page_IsValid) != 'undefined')
            if (Page_IsValid == false) {
                ForTabsError();
                ExpandAllSections();
                return;
            }
        document.getElementById(obj).value = newCaption;
        document.getElementById(obj).disabled = true;
        if (document.getElementById(obj + "Top") != null) {
            document.getElementById(obj + "Top").value = newCaption;
            document.getElementById(obj + "Top").disabled = true;
        }

        if (obj == "ctl00_ContentPlaceHolder3_btnSave")
            disableThisNoValidation("ctl00_ContentPlaceHolder3_btnSaveNew", "Save & Next");
        if (obj == "ctl00_ContentPlaceHolder3_btnSaveNew")
            disableThisNoValidation("ctl00_ContentPlaceHolder3_btnSave", "Save");
        disableThisNoValidation("ctl00_ContentPlaceHolder3_btnReset", "Reset");
        if ((obj == "ctl00_ContentPlaceHolder3_btnSave") || (obj == "ctl00_ContentPlaceHolder3_btnUpdate") || (obj == "ctl00_ContentPlaceHolder3_btnChangePassword") || (obj == "ctl00_ContentPlaceHolder3_btnImport")) // Added by Srivatsan for default page save
        {
            var id = obj.replace(/_/g, "$");
            storeInIEAutoCompleteCache();
            __doPostBack(id, '');
        }
    }
    catch (Ex) { }
}
function storeInIEAutoCompleteCache() {
    try {
        //http://support.microsoft.com/kb/329156
        window.external.AutoCompleteSaveForm(aspnetForm);
    }
    catch (ExIE) { }
}
function disableThisNoValidation(obj, newCaption)//used to disable buttons after click - sanal 22 Apr 2008
{
    try {
        document.getElementById(obj).value = newCaption;
        document.getElementById(obj).disabled = true;
        if (document.getElementById(obj + "Top") != null) {
            document.getElementById(obj + "Top").value = newCaption;
            document.getElementById(obj + "Top").disabled = true;
        }
    }
    catch (Ex) { }
}
function ChangeCalendarView(sender, args) {
    return false;
}
function openlookupwindow(hiddenfieldid, textboxid, bindid, strPK, pgs_id) {

    searchdata = document.getElementById("ctl00_ContentPlaceHolder3_" + textboxid).value;
    window.open("searchPopUp.aspx?bnd=" + bindid + "&pgs_id=" + pgs_id + "&CnID=" + hiddenfieldid + "&txtCnID=" + textboxid + "&SD=" + searchdata + "&PK=" + strPK + "", null, "toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=800,height=630,left=100,top=30").focus();
}
function openlookupwindowForMasterDetail(hiddenfieldid, textboxid, bindid, strPK, pgs_id, fld, strtablename) {

    searchdata = document.getElementById("ctl00_ContentPlaceHolder3_" + textboxid).value;
    //alert(searchdata);
    window.open("searchPopUp.aspx?bnd=" + bindid + "&pgs_id=" + pgs_id + "&CnID=" + hiddenfieldid + "&txtCnID=" + textboxid + "&SD=" + searchdata + "&PK=" + strPK + "&isMas=true&fld=" + fld + "&tbl=" + strtablename + "", null, "toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=800,height=630,left=100,top=30").focus();
}
function handleEmail(em_controlId) {
    try {
        if (document.getElementById(em_controlId) != null) {
            var em_value = document.getElementById(em_controlId).value;
            if (validateRegularExpression("\\w+([-+.\']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*", em_value)) {
                window.location = "mailto:" + em_value;
            }
            else {
                alert("Invalid E-mail");
            }
        }
    }
    catch (em_Exp) { }
}

function handleEmailField(em_controlId, UseMBEmail, strURL) {
    try {
        if (document.getElementById(em_controlId) != null) {
            var em_value = document.getElementById(em_controlId).value;
            if (validateRegularExpression("\\w+([-+.\']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*", em_value)) {
                if (UseMBEmail)
                    window.location.href = strURL;
                else
                    window.location = "mailto:" + em_value;
            }
            else
                alert("Invalid E-mail");
        }
    }
    catch (em_Exp) { }
}

function validateRegularExpression(reg_exp, str_value) {
    var reg_return = false;
    try {
        var regObject = new RegExp(reg_exp, "i");
        reg_return = regObject.test(str_value);
    }
    catch (reg_ex) { }
    return reg_return;
}

function ShowDivForActions(divid) // Added by srivatsan for showing Action Div in list pages (mouseover)
{
    if (document.getElementById("ctl00_ContentPlaceHolder3_" + divid) != null) {
        document.getElementById("ctl00_ContentPlaceHolder3_" + divid).style.display = "block";
        document.getElementById("ctl00_ContentPlaceHolder3_" + divid).focus();
    }
}

function HideDivForActions(divid) // Added by srivatsan for Hiding Action Div in list pages (mouseover)
{
    if (document.getElementById("ctl00_ContentPlaceHolder3_" + divid) != null) {
        document.getElementById("ctl00_ContentPlaceHolder3_" + divid).style.display = "none";
    }
}
function ExtendedDropDownAction(control_id, bindid, pgs_id, mn_id, type, storagefield, displayfield) {
    if (document.getElementById("ctl00_ContentPlaceHolder3_" + control_id) != null) {
        var hfaf_row_id = "";
        control = document.getElementById("ctl00_ContentPlaceHolder3_" + control_id);
        if (document.getElementById("ctl00_ContentPlaceHolder3_hf_RowID_" + control_id) != null) // Check for af_row_id
        {
            hfaf_row_id = control.value;
        }
        var linkURL = "";
        if (control.type == "select-one") {
            if (document.getElementById("ctl00_ContentPlaceHolder3_hf_DDE_DV_" + control_id) != null) {
                document.getElementById("ctl00_ContentPlaceHolder3_hf_DDE_DV_" + control_id).value = control.options[control.selectedIndex].text;
                //alert(document.getElementById("ctl00_ContentPlaceHolder3_hf_DDE_DV_"+control_id).value);
            }
            if (document.getElementById("ctl00_ContentPlaceHolder3_hf_DDE_" + control_id) != null) {
                if (document.getElementById("ctl00_ContentPlaceHolder3_hf_DDE_" + control_id).value != "") {
                    var strexpr = document.getElementById("ctl00_ContentPlaceHolder3_hf_DDE_" + control_id).value;
                    var SplitExpr = strexpr.split("|");
                    for (var i = 0; i < SplitExpr.length; i++) {
                        if (i == 0)// page
                            linkURL = linkURL + SplitExpr[i] + "?";
                        else if (i == 1) // pageset_id
                            linkURL = linkURL + "pgs_id=" + SplitExpr[i];
                        else if (i == 2) //menu_id
                            linkURL = linkURL + "&mn=" + SplitExpr[i];
                        else
                            linkURL = linkURL + SplitExpr[i];
                    }
                }
            }
            if (type == "EDT") {
                if (linkURL != "") {
                    strPK = document.getElementById("ctl00_ContentPlaceHolder3_" + control_id).value;
                    linkURL = linkURL + "&PK=" + strPK + "&isDDE=" + control_id + "&SF=" + storagefield + "&DF=" + displayfield + "";
                    //if(hfaf_row_id=="TYP"|| hfaf_row_id=="SRH"|| hfaf_row_id=="ADD")
                    if (hfaf_row_id == "" || hfaf_row_id == "TYP" || hfaf_row_id == "SRH" || hfaf_row_id == "ADD") {
                        alert("Please select a valid record to Edit");
                    }
                    else {
                        window.open('' + linkURL + '', 'Popup', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=800,height=630,left=100,top=30').focus();
                    }
                }
            }
            else {
                if (control.options[control.selectedIndex].value == "TYP") {
                    var data = prompt("Enter the value to be selected", "");
                    if (data != "" && data != null) {
                        if (document.getElementById("ctl00_ContentPlaceHolder3_hf_DDE_DV_" + control_id) != null) {
                            document.getElementById("ctl00_ContentPlaceHolder3_hf_DDE_DV_" + control_id).value = data;
                        }
                        var typevalue = "0";
                        for (var j = 0; j < control.options.length; j++) {
                            if (control.options[j].text == data) {
                                control.options[j].selected = true;
                                typevalue = "1";
                                break;
                            }
                        }
                        if (typevalue == "0") // Add value to drop down if value does not exists
                        {
                            var opt = document.createElement("option");
                            control.options.add(opt, 0);
                            opt.text = data;
                            opt.value = "";
                            control.selectedIndex = 0;
                        }
                    }
                }
                if (control.options[control.selectedIndex].value == "ADD") {
                    if (linkURL != "") {
                        linkURL = linkURL + "&isDDE=" + control_id + "&SF=" + storagefield + "&DF=" + displayfield + "";
                        window.open('' + linkURL + '', 'Popup', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=800,height=630,left=100,top=30').focus();
                    }
                }
                if (control.options[control.selectedIndex].value == "SRH") {
                    //window.open("searchPopUp.aspx?bnd="+bindid+"&pgs_id="+pgs_id+"&CnID="+hiddenfieldid+"&txtCnID="+textboxid+"&SD="+searchdata+"&PK="+strPK+"&isMas=true&fld="+fld+"&tbl="+strtablename+"",null,"toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=800,height=630,left=100,top=30");
                    window.open("searchPopUp.aspx?bnd=" + bindid + "&pgs_id=" + pgs_id + "&mu=" + mn_id + "&CnID=" + control_id + "&typ=DDE", null, "toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=800,height=630,left=100,top=30").focus();
                }
            }

        }
    }
}
function SetValueForDDE(control_id, storagefield, displayfield, pagemode) {
    if (top.window.opener.document.getElementById("ctl00_ContentPlaceHolder3_" + control_id) != null) {
        var TopControl = top.window.opener.document.getElementById("ctl00_ContentPlaceHolder3_" + control_id);
        var storagevalue = "";
        var displayvalue = "";
        if (document.getElementById("ctl00_ContentPlaceHolder3_" + storagefield) != null) {
            storagevalue = document.getElementById("ctl00_ContentPlaceHolder3_" + storagefield).value;
        }
        else if (document.getElementById("ctl00_" + storagefield) != null) {
            storagevalue = document.getElementById("ctl00_" + storagefield).value;
        }
        if (document.getElementById("ctl00_ContentPlaceHolder3_" + displayfield) != null) {
            displayvalue = document.getElementById("ctl00_ContentPlaceHolder3_" + displayfield).value;
            if (document.getElementById("ctl00_ContentPlaceHolder3_" + displayfield).type == "checkbox") {
                displayvalue = document.getElementById("ctl00_ContentPlaceHolder3_" + displayfield).checked;
            }
        }
        if (storagevalue != "" || displayvalue != "") {
            if (pagemode == "EDT") {
                for (var i = 0; i < TopControl.options.length; i++) {
                    if (TopControl.options[i].value == storagevalue) {
                        TopControl.selectedIndex = i;
                        //TopControl.selectedIndex.text = displayvalue;
                        TopControl.options[i].text = displayvalue;
                        break;
                    }
                }
            }
            else if (pagemode == "ADD") {
                var opt = top.window.opener.document.createElement("option");
                TopControl.options.add(opt, 0);
                //alert(displayvalue);
                opt.text = displayvalue;
                opt.value = storagevalue;
                //TopControl.selectedIndex = 0;
                TopControl.options[0].selected = true;
            }
            if (top.window.opener.document.getElementById("ctl00_ContentPlaceHolder3_hf_DDE_DV_" + control_id) != null) {
                top.window.opener.document.getElementById("ctl00_ContentPlaceHolder3_hf_DDE_DV_" + control_id).value = displayvalue;
            }

        }
        if (TopControl.value == "TYP" || TopControl.value == "SRH" || TopControl.value == "ADD")
        //if(storagevalue=="TYP"||storagevalue=="SRH"||storagevalue=="ADD")
        {
            //alert("Please Select a valid record to Save");
            return false;
        }

        self.close();
    }

}

/************Added By Dhanapal On Dec 16 2010************************/
function getTableObj() {
    if (document.getElementById("ctl00_ContentPlaceHolder3_tblDynamicMain") || document.getElementById("ctl00_ContentPlaceHolder3_tblDynamicMain1")) {
        if (document.getElementById("ctl00_ContentPlaceHolder3_tblDynamicMain")) {
            var tableobj = document.getElementById("ctl00_ContentPlaceHolder3_tblDynamicMain");
        } else {
            var tableobj = document.getElementById("ctl00_ContentPlaceHolder3_tblDynamicMain1");
        }

        return tableobj;
    }
}

function ExpandAllSections() {
    try {
        var tableObj = getTableObj();
        if (tableObj.tagName == "TABLE") { //TO Check Whether it is a Table Or Not 
            var trList = tableObj.getElementsByTagName("tr");
            var ContentHoldertr = trList[2]; //The Second Row Contains the Total Dynamic Table
            var ContentHoldertrtd = ContentHoldertr.getElementsByTagName("td");
            var tablecollecObj = ContentHoldertrtd[0].getElementsByTagName("table");

            for (var i = 0; i < tablecollecObj.length; i++) {
                if (tablecollecObj[i].id.indexOf("ctl00_ContentPlaceHolder3_tbl") == "0") {
                    ExpandAllSectionsChild(tablecollecObj[i]);
                    break;
                }

                //alert(tablecollecObj[i].id);
            }
        }
    }
    catch (Ex) { }

}

function ExpandAllSectionsChild(dynamictable) {
    var dynamictableobj = dynamictable;
    var childtrList = dynamictableobj.getElementsByTagName("tr");
    for (var index = 0; index < parseInt(childtrList.length); index++) {
        childtrList[index].style.display = '';
        //alert(childtrList[index].id);
    }

}

function handleDropDownLookup(constant, controlId, includeEmptyValues, recCount, DIVID) {
    //document.getElementById('" + constant + controlId + "').selectedIndex=" + (includeEmptyValues == false ? recCount.ToString() : Convert.ToString(recCount + 1)) + ";document.getElementById('" + DIVID + "').style.display = 'none';return false;
    var recCountNew = includeEmptyValues == false ? parseInt(recCount) : parseInt(recCount + 1);
    document.getElementById(constant + controlId).selectedIndex = recCountNew;
    document.getElementById(DIVID).style.display = 'none';
    try {
        document.getElementById(constant + controlId).onchange();
    }
    catch (excee) { }
    return false;
}
//sanal - set theme css for save, reset and all buttons
$(document).ready(function () {
    //$("input[id^=ctl00_ContentPlaceHolder3_btnSave]").each(function(){
    //    $(this).addClass('dynamicpage_buttons');
    //});
    //$("input[id^=ctl00_ContentPlaceHolder3_btnSaveNew]").each(function(){
    //    $(this).addClass('dynamicpage_buttons');
    //});
    //$("input[id^=ctl00_ContentPlaceHolder3_btnReset]").each(function(){
    //    $(this).addClass('dynamicpage_buttons');
    //});
    //$("input[id^=ctl00_ContentPlaceHolder3_btnAddNew]").each(function(){
    //    $(this).addClass('dynamicpage_buttons');
    //});
    $(":button").each(function () {
        $(this).addClass('dynamicpage_buttons');
    });
    $(":submit").each(function () {
        $(this).addClass('dynamicpage_buttons');
    });
    //sanal on april 17, 2012 - support large text area
    var textarea_loc = document.location.href;
    if (textarea_loc.toLowerCase().indexOf("dynamicscreen.aspx") > -1) {
        $('textarea').each(function () {
            try {
                if ($(this).parent().get(0).tagName.toLowerCase() == "td") {
                    var parentTd = $(this).parent();
                    var parentTr = parentTd.parent();
                    var count = parentTr.children().length;
                    var index = parentTd.index();
                    if (count - index > 2) {
                        var curCelWidth = parentTd.outerWidth(true);
                        var nextCellWidth = parentTd.next().outerWidth(true);
                        var haveContent = false;
                        for (var j = index + 1; j < count - 1; j++) {
                            haveContent = !($.trim(parentTr.children().eq(j).html()) == "" || $.trim($(parentTr).children().eq(j).html()) == "&nbsp;");
                            if (haveContent) break;
                        }
                        if (haveContent == false) {

                            for (var j = index + 1; j < count - 1; j++)
                                parentTd.next().remove();
                            parentTd.attr('colspan', count - index - 1);
                            //$(this).width($(this).parent().width()-160);
                            var newWidth = ($(this).outerWidth(true) * 2) + (curCelWidth - $(this).outerWidth(true)) + nextCellWidth + 4;
                            $(this).width(newWidth);
                        }
                    }
                }
            }
            catch (Exced) { }
        });
    }
    $('textarea').autogrow();
    handleViewMode();
    disableReminderButton();
    attachAutoComplete4Lookup();
    makeHeaderElementsVertical();
    LoadRecentlyVisited();
    LoadSearch(); // Added by 'Imran gani'
    LoadQuickLinks();
    //available in quicklinks.js
    setImageBasedOnTheme();
    LoadSectionsAsTabs(); // Added by 'Imran gani' on 31-May-2013
    $("#ctl00_ContentPlaceHolder3_datasheet td img").parent("td").css("padding-right", "4px"); // Added by 'Imran Gani' on 18-Sep-2014, for datasheet image padding
    setTimeout('setDivContentSize()', 0); // Added by 'Imran Gani' on 19-Sep-2014, for callback of setting content size when collapse the sidebar
});
//sanal - aug 08, 2011 manage password enhancements
var vm_loc_cur_page = document.location.href;
//check for pwd_org elements and if the value exists, put it in the password/text field
if (vm_loc_cur_page.toLowerCase().indexOf("dynamicscreen.aspx") > -1) {
    $(document).ready(function () {
        $("input[id^=ctl00_ContentPlaceHolder3_pwd_org_]").each(function () {
            if ($(this).val().length > 0) {
                $('#' + $(this).attr('id').replace("pwd_org_", "")).val($(this).val());
                if ($('#' + $(this).attr('id').replace("pwd_org_", "")).is('input:password'))//this handles the view mode
                    $('#' + 'span_' + $(this).attr('id').replace("pwd_org_", "")).text(Array(($(this).val().length) + 1).join("*"));
                else
                    $('#' + 'span_' + $(this).attr('id').replace("pwd_org_", "")).text($(this).val());
            }
        });
    });
}

//code added by Sampath on 08-Dec-2011 for ipp redirect and free edition home page image change
$(document).ready(function () {
    if (document.getElementById("ctl00_hfsourceapp") != null) {
        if (document.getElementById("ctl00_hfsourceapp").value == "ipp") {
            if (vm_loc_cur_page.toLowerCase().indexOf("instructions.aspx") > -1) {
                $("area[name^=import]").each(function () {
                    $(this).attr('href', 'import_ipp.aspx?mn=5106&amp;pgs_id=335dea653698e7a7');
                });
                $("img[src$='ezimages/EC_App_Flow_FE.gif']").attr('src', 'ezimages/EC_App_Flow.gif');
            }
        }
    }
});
function LoadRecentlyVisited() {


    $.ajax({
        url: "mb_ajaxhandler.aspx?action=recently_visited",
        dataType: "json",
        cache: false,
        success: function (msg) {
            GetRecentlyVisited(msg);
        }
    });


}
function LoadQuickLinks() {


    $.ajax({
        url: "mb_ajaxhandler.aspx?action=Quick_links",
        dataType: "json",
        cache: false,
        success: function (Jstr) {
            GetQuckLinks(Jstr);
        }
    });


}
function GetQuckLinks(Jstr) {
    var logo = "Default.PNG";
    var td = document.getElementById("td_ql");
    var displayField = "";
    var New_window = new Boolean();
    try {
        if (Jstr.data != "") {
            for (var i = 0; i < Jstr.data.length; i++) {
                if (Jstr.data[i].parent_link == null) {
                    displayField += "<div class=\"ParentLink\" style=\"cursor:pointer;width:100%;vertical-align:middle;padding-top:5px;margin-bottom:2px;height:20px;\" onclick=\"javascript:ShowHideChild('" + Jstr.data[i].af_row_id + "');\" ><span style=\"text-align:left;padding-left:4px;float: left;vertical-align:middle;\"> " + Jstr.data[i].link_name + "</span><span style=\"text-align:right;padding-right:2px;float: right;\"><img style=\"padding-right:2px;\" id=\"img_" + Jstr.data[i].af_row_id + "\" style=\"cursor:pointer;\" alt='Click to collapse' src='Images/collapse3.gif'/></span></div>";
                    displayField += "<div id='" + Jstr.data[i].af_row_id + "' class=\"ChildLink\" style=\"cursor:pointer;padding-left:4px;text-align:left;margin:0px 0px 5px 0px; \">";
                }
                for (var j = 0; j < Jstr.data.length; j++) {
                    if (Jstr.data[j].parent_link == Jstr.data[i].link_name) {
                        if (Jstr.data[j].logo != "") {
                            logo = Jstr.data[j].logo
                        }

                        if (logo == null)
                            logo = "Default.PNG";

                        displayField += "<img src=\"Images/MBIcons/Small/" + logo + "\"></img>&nbsp; &nbsp;<a class='ChildLink' style=\"\" href='" + Jstr.data[j].link + "'" + (Boolean(Jstr.data[j].is_new_window) == true ? " target= '_blank'" : "") + "   title='" + Jstr.data[j].link_name + "'>" + Jstr.data[j].link_name + "</a>";
                        displayField += "<br />";

                    }


                }
                if (Jstr.data[i].parent_link == null)
                    displayField += "</div>";
                td.innerHTML = displayField;

                //div_QuickLinks.appendChild(div_QuickLinkschild);
            }
            //$('#td_test').append(div_QuickLinks);
        }
    }
    catch (Ex) {
        return false;
    }
    handleQuickLinks();
}
function GetRecentlyVisited(msg) {
    var displayField = "";
    var navigateURL = "";
    var ImagePath = "";
    try {
        if (msg.data != "") {

            for (var i = 0; i < msg.data.length; i++) {
                var divObj = document.createElement('div');
                divObj.id = "div_recentvist_" + i;
                navigateURL = msg.data[i].NavigatePage + "?mn=" + msg.data[i].af_row_id + "&pgs_id=" + msg.data[i].pageset_id;
                ImagePath = "Images/MBIcons/Small/" + msg.data[i].Image;

                displayField = "<a class=\"defaultFont\" title=\"" + $('<div/>').text(msg.data[i].menu_name).html() + "\" style='text-decoration:none;padding:2px 5px 2px 5px;font-family:Arial;font-size:11px;' href=\"" + navigateURL + "\">" + "<img border='0' src=\"" + ImagePath + "\"> &nbsp;" + $('<div/>').text(msg.data[i].menu_name).html() + "</a>";
                divObj.innerHTML = displayField;
                $('#td_recentVisit').append(divObj);
            }
        }
    }
    catch (Ex) {
        return false;
    }


}

function attachAutoComplete4Lookup() {
    $("input[type=text]").each(function () {
        var lookupElement = $(this).nextAll().eq(1);
        if ($(lookupElement).attr('class') == "SearchPopup") {
            var val = $(lookupElement).attr('onclick').toString();
            var vals = val.split("'");
            //source: "mb_ajaxhandler.aspx?action=bnd&bndid=" + vals[5] + "&val=" + encodeURIComponent($(this).val()),
            //if (parseInt(vals[5]) > 0) {
            if (vals[5] != "") {
                $(this).autocomplete({
                    source: function (request, response) {
                        $.ajax({
                            url: "mb_ajaxhandler.aspx?action=bnd&bndid=" + vals[5] + "&limit=10&val=" + encodeURIComponent(request.term), //don't pass limit, to fetch all records.
                            dataType: "json",
                            cache: false,
                            success: function (msg) {
                                response(msg);
                            }
                        })
                    },
                    minLength: 3
                });
            }
        }
    });
    //$('.ui-autocomplete').css('width','300px');   
}
function makeHeaderElementsVertical() {//by sanal to vertical align header elements
    $(".pgForm_title").find('img').css('vertical-align', 'middle');
    $(".pgForm_title").find('span').css('vertical-align', 'middle');
    $(".Dynamic_PageHeaderRow").find('img').css('vertical-align', 'middle');
}
function setImageBasedOnTheme() {
    var colo = $('#ctl00_lbltitle').css('color');
    if (colo == 'rgb(255, 255, 255)' || colo == '#ffffff') {
        $('#ctl00_Image2').attr('src', 'images/BlackGray/arrowDown.gif');
    }
}
function disableReminderButton() {
    $('#ctl00_task_completed').attr('disabled', 'disabled');
    $('#ctl00_dismiss').attr('disabled', 'disabled');
    $('#ctl00_defer').attr('disabled', 'disabled');
}

//Use to provide video
// Parameter: youtubeURL - encoded url, targetControlID - Control id the video should get placed.
function showVideo(youtubeURL, targetControlID) {
    var divWidth = 640;
    var width = ($("#" + targetControlID).parents("table:first").width()) - 50;
    var aspectSetupHt = (width / 16 * 9);
    aspectSetupHt = Math.round(aspectSetupHt);
    $("#" + targetControlID).attr("width", width);
    $("#" + targetControlID).attr("height", aspectSetupHt);
    var divContent = "<iframe width='" + width + "' height='" + aspectSetupHt + "' frameborder='0' src='" + youtubeURL + "' allowfullscreen></iframe>";
    $("#" + targetControlID).html(divContent);

    if (document.getElementById(targetControlID).style.display == "block")
        document.getElementById(targetControlID).style.display = "none";
    else
        document.getElementById(targetControlID).style.display = "block";
}